Add a test for build commands with build commands
authorAlex Crichton <alex@alexcrichton.com>
Sat, 1 Nov 2014 02:16:39 +0000 (19:16 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 5 Nov 2014 19:37:34 +0000 (11:37 -0800)
tests/test_cargo_compile_custom_build.rs

index 9eac0c63f9da29f4057315a219dd502c166fba65..872d87116010e5ba4fa860f3dec8d28e3d24b024 100644 (file)
@@ -615,3 +615,65 @@ Caused by:
   Process didn't exit successfully: [..]
 "));
 })
+
+test!(build_cmd_with_a_build_cmd {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.5.0"
+            authors = []
+            build = "build.rs"
+
+            [build-dependencies.a]
+            path = "a"
+        "#)
+        .file("src/lib.rs", "")
+        .file("build.rs", "
+            extern crate a;
+            fn main() {}
+        ")
+        .file("a/Cargo.toml", r#"
+            [project]
+            name = "a"
+            version = "0.5.0"
+            authors = []
+            build = "build.rs"
+
+            [build-dependencies.b]
+            path = "../b"
+        "#)
+        .file("a/src/lib.rs", "")
+        .file("a/build.rs", "extern crate b; fn main() {}")
+        .file("b/Cargo.toml", r#"
+            [project]
+            name = "b"
+            version = "0.5.0"
+            authors = []
+        "#)
+        .file("b/src/lib.rs", "");
+
+    assert_that(p.cargo_process("build").arg("-v"),
+                execs().with_status(0)
+                       .with_stdout(format!("\
+{compiling} b v0.5.0 (file://[..])
+{running} `rustc [..] --crate-name b [..]`
+{compiling} a v0.5.0 (file://[..])
+{running} `rustc build.rs [..] --extern b=[..]`
+{running} `[..]a-[..]build-script-build`
+{running} `rustc [..]lib.rs --crate-name a --crate-type lib -g \
+    -C metadata=[..] -C extra-filename=-[..] \
+    --out-dir [..]target[..]deps --dep-info [..]fingerprint[..]dep-lib-a \
+    -L [..]target[..]deps -L [..]target[..]deps`
+{compiling} foo v0.5.0 (file://[..])
+{running} `rustc build.rs --crate-name build-script-build --crate-type bin -g \
+    --out-dir [..]build[..]foo-[..] --dep-info [..]fingerprint[..]dep-[..] \
+    -L [..]target -L [..]target[..]deps \
+    --extern a=[..]liba-[..].rlib`
+{running} `[..]foo-[..]build-script-build`
+{running} `rustc [..]lib.rs --crate-name foo --crate-type lib -g \
+    -C metadata=[..] -C extra-filename=-[..] \
+    --out-dir [..]target --dep-info [..]fingerprint[..]dep-lib-foo \
+    -L [..]target -L [..]target[..]deps`
+", compiling = COMPILING, running = RUNNING).as_slice()));
+})